<template>
    <div id="background">
        <el-container style="height:100%;" direction="vertical">
            <!-- <el-header id="gouMaiHead">
                <img class="gmIcon" src="../../assets/img/mine/back.png" @click="back">
                <span class="gmHead">我的购买</span>
            </el-header> -->
            <el-header id="gouMaiHeadPosition">
                <el-row type="flex" style="height:80%;display:flex;align-items: flex-end">
                    <el-col :xs="2" :sm="2" :md="2" :offset="1" class="imgCol">
                        <img v-bind:src="backIcon" class="backSize" @click="back" />
                    </el-col>
                    <el-col :xs="6" :sm="6" :md="6" :offset="6" class="imgCol">
                        <span class="titleSize">我的购买</span>
                    </el-col>
                </el-row>
            </el-header>
            <el-main id="gouMaiMain">
                <el-card class="daoHangCard" :body-style="{ padding: '0px'}">
                    <el-row type="flex" class="gmDaoHang" >
                        <el-button type="text" @click="changeKc" class="daoHangBtn" style="width:86.6px;">课程 ({{kcNum}})</el-button>
                        <el-divider direction="vertical"></el-divider>
                        <el-button type="text" @click="changePx" class="daoHangBtn" style="width:84.6px;">培训 ({{pxNum}})</el-button>
                        <el-divider direction="vertical"></el-divider>
                        <el-button type="text" @click="changeKs" class="daoHangBtn" style="width:86.6px;">考试 ({{ksNum}})</el-button>
                    </el-row>
                </el-card>
                <div v-if="type=='kc'">
                    <el-row :gutter="10" style="padding-left:10px;padding-right:10px;" >
                    <el-col :span="12" v-for="(value,key) in keChengList" :key="key"  >
                        <div class="gmBox" >
                            <el-card class="kcKuang" :body-style="{ padding: '0px'}" style="text-align:center;margin:0px;">
                                <div style="position:relative;color:#707070;">
                                    <!-- <div style="width:123px;height:69px;"> -->
                                    <img class="gmImg" v-bind:src="value.picture" >
                                    <!-- </div> -->
                                    <!-- <div style="position:absolute; z-index:2;top:25%;left:17%;">
                                       <el-row type="flex" class="gmContent1" >
                                          <span style="font-size:15px;margin-bottom:4px;">
                                                {{value.name}}
                                          </span>
                                        </el-row>
                                        <el-row type="flex" class="gmContent1">
                                            <span style="font-size:15px;">
                                                {{'讲师：'+value.teacher}}
                                            </span>
                                        </el-row>
                                    </div> -->
                                </div>
                                <div class="gmContent2" style="margin-bottom:6px; color:#707070;">
                                    <span style="font-size:12px;">
                                         {{value.name}}
                                    </span>
                                    <span  style="font-size:10px;">
                                        {{value.teacher+' '+value.number+'讲'}}
                                    </span>
                                </div>
                            </el-card>
                        </div>
                    </el-col>
                    </el-row>
                </div>
                <div v-else-if="type=='px'">
                    <!-- <el-row :gutter="10" style="padding-left:10px;padding-right:10px;">
                    <el-col :span="12" v-for="(value,key) in peiXunList" :key="key" >
                        <div class="gmBox" >
                            <el-card class="kcKuang" :body-style="{ padding: '0px'}" style="text-align:center;margin:0px;">
                                <div style="position:relative;color:#707070;">
                                    <img class="gmImg" src="../../assets/img/mine/gmkuang.png">
                                    <div style="position:absolute; z-index:2; top:25%;left:17%;" >
                                        <el-row type="flex" class="gmContent1">
                                            <span style="font-size:15px;margin-bottom:4px;">
                                            {{value.pxTitle}}
                                            </span>
                                        </el-row>
                                        <el-row type="flex" class="gmContent1">
                                            <span style="font-size:15px;">
                                            {{'讲师：'+value.pxTeacher}}
                                            </span>
                                        </el-row>
                                    </div>
                                </div>
                                <div class="gmContent2" style="margin-bottom:6px; color:#707070;">
                                    <span style="font-size:12px;">
                                         {{value.pxTitle}}
                                    </span>
                                    <span  style="font-size:10px;">
                                        {{value.pxTeacher+' '+value.pxCount+'课时'}}
                                    </span>
                                </div>
                            </el-card>
                        </div>
                    </el-col>
                    </el-row> -->
                </div>
                <div v-else>
                    <!-- <el-row :gutter="10" style="padding-left:10px;padding-right:10px;">
                    <el-col :span="12" v-for="(value,key) in kaoZhengList" :key="key" >
                        <div class="gmBox" >
                            <el-card class="kcKuang" :body-style="{ padding: '0px'}" style="text-align:center;margin:0px;">
                                <div style="position:relative;color:#707070;">
                                    <img class="gmImg" src="../../assets/img/mine/gmkuang.png">
                                    <div style="position:absolute; z-index:2; left:25%; top:25%;" >
                                        <el-row type="flex" class="gmContent1">
                                            <span style="font-size:15px;margin-bottom:4px;position:relative;left:12%;">
                                            {{value.kzTitle}}
                                            </span>
                                        </el-row>
                                        <el-row type="flex" class="gmContent1">
                                           <span style="font-size:15px;position:relative;left:10%;">
                                           上岗证
                                           </span>
                                        </el-row>
                                    </div>
                                </div>
                                <div class="gmContent2" style="margin-bottom:6px; color:#707070;">
                                    <span style="font-size:12px;">{{value.kzTitle+'上岗证'}}</span>
                                </div>
                            </el-card>
                        </div>
                    </el-col>
                    </el-row> -->
                </div>
            </el-main>
        </el-container>
    </div>
</template>

<script>
import backIcon from '../../assets/img/mine/back.png'
import { type } from 'os';
export default {
    data(){
        return{
            backIcon:backIcon,
            kcNum:0,
            pxNum:0,
            ksNum:0,
            type:'kc',
            normalHeight:document.documentElement.clientHeight,
            keChengList:[ ],
            peiXunList:[
                {
                    pxTitle:'电工基础',
                    pxCount:'8',
                    pxTeacher:'孟老师',
                },{
                    pxTitle:'电工基础',
                    pxCount:'8',
                    pxTeacher:'孟老师',

                },
            ],
             kaoZhengList:[
                {
                    kzTitle:'维修电工',
                },
            ],
            
        }
    },
    mounted(){
        var bg = document.getElementById("background");
       // this.normalHeight=document.documentElement.clientHeight;
        console.log("height:"+this.normalHeight);
        bg.style.height = this.normalHeight+"px";
        bg.style.backgroundColor = "#FFFFFF"
        bg.style.margin = "0px";

        var head=document.getElementById("gouMaiHeadPosition");
        var headHeight=this.normalHeight/30 *4 ;
        console.log("headHeight:"+headHeight);
        head.style.height=headHeight+"px";

        var main=document.getElementById("gouMaiMain");
        var mainHeight=this.normalHeight/30 *24 ;
        main.style.height=mainHeight+"px";

        this.begindo();
    },
    methods:{
        begindo(){
            if(this.type=='kc'){
                console.log(this.type);
                var URL=this.IP.IP+'/course/courseMine'
                this.$ajax({
                    method:'get',
                    url:URL,
                }).then(response =>{
                console.log(response);
                this.keChengList = response.data.data;
                console.log(this.keChengList);
                this.kcNum=response.data.data.length;
                }).catch(error => {
                console.log('sad');
                });
            }
        },    
        changeKc(){
            this.type="kc";
            this.begindo();
        },
        changePx(){
            this.type="px";
            
        },
        changeKs(){
            this.type="ks";
            
        },
        back(){
            console.log("back:");
            this.$router.go(-1);
        },

    }
}
</script>

<style>
.daoHangBtn{
    margin-top:5px;
    margin-bottom: 5px;
    font-size:16px;
    color:#53cdf5;
}
.gmContent1{
    display:flex;
    align-items:center;
    justify-content:center;
}
.gmBox{
    margin-top: 10px;
    margin-left: 5px;
    margin-right: 5px;
}
#gouMaiHeadPosition {
  background-color: #53cdf5;
}
.backSize{
    height: 26px;
}
.titleSize{
    font-size:1.125em;
    color:#ffffff
}
@media screen and (max-height: 600px){
  .backSize{
      height: 22px;
  }
  .titleSize{
      font-size: 1em;
  }
}

.gmImg{
   /* width:auto;
   height:auto;
   max-width:100%;
   max-height:100%; */
   width:100%;
   height:69px;
}
.daoHangCard{
    margin-top: 10px;
    margin-left: 10px;
    margin-right: 10px;
}
.gmDaoHang{
    /* position: relative;
    left:8%; */
    display:flex;
    align-items:center;
    justify-content:center;
}
/* .gmIcon{
    position: relative;
    top:40%;
    float:left;
    width:30px;
    height:30px;
}
.gmHead{
    position: relative;
    top:15%;
    right: 8px;
    font-size: 20px;
} */
#gouMaiMain{
    padding: 10px;
    background: #FFFFFF;
}

/* #gouMaiHead{
    background-color: #53cdf5 !important;
    height: 45px;
    text-align: center;
    line-height: 60px;
    color: #FFFFFF;
    width: 100%;
} */


</style>
